<?php

namespace App\Http\Resources\panyuan;

use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Facades\Storage;

class GonggaoCollection extends ResourceCollection
{
    /**
     * Transform the resource collection into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'code'=>'success',
            'message'=>'请求成功',
            'data'=>$this->collection->map(function($item){
                    return [
                        'title'=>$item->title,
                        'time'=>$item->created_at->toDateString(),
                        'logo'=>Storage::url($item->logo),
                        'id'=>$item->id
                    ];
            })
        ];
    }
}
